import React from 'react';
import {AppState} from 'react-native';

import {useMount, useUnmount} from 'ahooks';
import {useSelector, useDispatch} from 'react-redux';
import {setAppRunState} from './store';

export default ({children}) => {
  const dispatch = useDispatch();
  const stateChange = v => {
    console.log('App状态', v);
    dispatch(setAppRunState(v));
  };
  useMount(() => {
    AppState.addEventListener('change', stateChange);
  });
  return children;
};
